#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
const int N = 1e6 + 10;
int a[N], b[N];
int main(){
    int m, n;
    scanf("%d%d", &m, &n);

    int num = 0;
    for (int i = 0; i < m;i++){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &b[i]);
    }
    sort(a, a + m);
    //sort(b, b + n);  这个其实不用排序
    while(n-1>=0){
        int left = 0;
        int right = m;
        while (left < right)
        {
            int mid = left + (right - left) / 2;
            if (a[mid] < b[n-1]){
                left = mid + 1;
            }
            else{
                right = mid;
            }
        }
        int begin = left;
        left = 0;
        right = m;
        while (left < right)
        {
            int mid = left + (right - left + 1) / 2;
            if (a[mid] > b[n - 1])
            {
                right = mid - 1;
            }
            else
            {
                left = mid;
            }
        }
        int i = abs(b[n - 1] - a[begin]);
        int j = abs(b[n - 1] - a[left]);
        num += (i > j) ? j : i;
        n--;
    }
    cout << num;

    return 0;
}